<?php
include "method/win.php";

if(!isset($_SESSION['user'])){
    show_msg("请先登录!","login.php");
}
if(isset($_GET['action'])){
    logout();
}
if(isset($_GET['page'])){
    $page = $_GET['page'];
}else {
    $page = 1;
}
if(isset($_POST['upload'])){
    wbpublic($_FILES['imgfile'], $_FILES['imgfile']['tmp_name'], $_SESSION['user'], date("Y-m-d H:i:s"), $_POST['txt_weibo']);
}
$usersql = "select * from weibo_user where user_name='".$_SESSION['user']."'";
$userres = $conn->query($usersql);
$userrow = $userres->fetch_assoc();

$gzsql = "select * from weibo_relation where fans='".$userrow['user_name']."'";
$gzres = $conn->query($gzsql);

$fansql = "select * from weibo_relation where user='".$userrow['user_name']."'";
$fanres = $conn->query($fansql);

$wbsql = "select * from weibo_list where author='".$userrow['user_name']."'";
$wbres = $conn->query($wbsql);

$scsql = "SELECT weibo_user.*, weibo_list.* FROM weibo_user, weibo_list, weibo_sc WHERE weibo_user.user_name=weibo_list.author and weibo_list.weibo_id=weibo_sc.weibo_id and weibo_sc.user='".$userrow['user_name']."' order by weibo_list.public_time desc";
$scres = $conn->query($scsql);

$zansql = "SELECT weibo_user.*, weibo_list.* FROM weibo_user, weibo_list, weibo_zan WHERE weibo_user.user_name=weibo_list.author and weibo_list.weibo_id=weibo_zan.weibo_id and weibo_zan.user='".$userrow['user_name']."' order by weibo_list.public_time desc";
$zanres = $conn->query($zansql);

$hotsql = "SELECT weibo_user.*, weibo_list.* FROM weibo_user, weibo_list WHERE weibo_list.author=weibo_user.user_name ORDER BY weibo_list.weibo_hot DESC";
$hotres = $conn->query($hotsql);

$newsql = "SELECT weibo_user.*, weibo_list.* FROM weibo_user, weibo_list WHERE weibo_user.user_name=weibo_list.author ORDER BY weibo_list.public_time DESC";
$newres = $conn->query($newsql);
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>我的首页</title>
    <link rel="stylesheet" href="../lib/bootstrap/css/bootstrap.css">
    <link rel="stylesheet" href="css/base.css">
    <link rel="stylesheet" href="css/index_loginafter.css">
    <script src="../lib/jquery/jquery.js" type="text/javascript"></script>
    <script src="../lib/bootstrap/js/bootstrap.js" type="text/javascript"></script>
</head>
<body>
<!--顶部导航条-->
<nav class="navbar navbar-default">
    <div class="container-fluid">
        <!--头部logo-->
        <div class="navbar-header">
            <a class="navbar-brand" href="#"><em><img src="../img/logo.jpg" height=30 width=30></em><em>小狗微博</em></a>
        </div>

        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <!--搜索框-->
            <form class="navbar-form navbar-left" role="search" method="post" action="search_loginafter.php">
                <div class="form-group">
                    <input type="text" class="form-control" style="width: 400px" placeholder="Search" name="str-search">
                </div>
                <button type="sumbit" class="btn btn-default" name="search-btn">搜索</button>
            </form>
            <ul class="nav navbar-nav navbar-right">
                <li><a href="index_loginafter.php">首页</a></li>
                <li><a href="person_loginafter.php"><?php echo $_SESSION['user']?></a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">我的消息 <span class="caret"></span></a>
                    <ul class="dropdown-menu">
                        <li><a href="inbox.php?page=1">@我</a></li>
                        <li><a href="inbox.php?page=2">评论</a></li>
                        <li><a href="inbox.php?page=3">回复</a></li>
                        <li><a href="inbox.php?page=4">赞</a></li>
                    </ul>
                </li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">个人中心 <span class="caret"></span></a>
                    <ul class="dropdown-menu">
                    	<li><a href="fixpw.php">修改密码</a></li>
                        <li><a href="fixtx.php">修改头像</a></li>
                        <li><a href="index_loginafter.php?action=logout">退出登录</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
</nav>

<!--版心-->
<div class="index-warp clearfix">
    <!--左边导航栏-->
    <div class="nav-left">
        <ul class="list-group">
            <a href="index_loginafter.php?page=1"><li class="list-group-item click" id="nav-1">首页</li></a>
            <a href="index_loginafter.php?page=2"><li class="list-group-item" id="nav-2">我的收藏</li></a>
            <a href="index_loginafter.php?page=3"><li class="list-group-item" id="nav-3">我的赞</li></a>
            <a href="index_loginafter.php?page=4"><li class="list-group-item" id="nav-4">热门微博</li></a>
            <a href="index_loginafter.php?page=5"><li class="list-group-item" id="nav-5">最新微博</li></a>
        </ul>
    </div>

    <!--版心左边-->
    <div class="left-warp">
        <!--首页-->
        <div class="warp-sy choose-2">
            <!--顶条-->
            <div class="tip-bar">
                <span>首页</span>
            </div>
            <!--微博发布框-->
            <div class="public-box clearfix">
                <p>发条心情微博吧</p>
                <form action="" method="post" enctype="multipart/form-data" name="upload_form" id="upload_form">
                    <textarea rows="5" id="txt_weibo" name="txt_weibo"></textarea>
                    <label>选择图片文件</label>
                    <input name="imgfile" id="img-str" type="file" accept="image/gif, image/jpeg" style="width: 500px; display: block"/>
                    <input name="upload" type="submit" value="上传" style="display: block; float: right; width: 100px"/>
                </form>
            </div>
            <!--微博-->
   			<?php 
   			if($gzres->num_rows){
   			    $firstsyrow = $gzres->fetch_assoc();
   			    $str = "weibo_list.author='".$firstsyrow['user']."' ";
   			    while ($otherrows=$gzres->fetch_assoc()){
   			        $str = $str."|| weibo_list.author='".$otherrows['user']."' ";
   			    }
   			    $sysql="SELECT weibo_list.*, weibo_user.* FROM weibo_user, weibo_list WHERE weibo_user.user_name=weibo_list.author and (".$str.") order by weibo_list.public_time desc";
   			    $syres=$conn->query($sysql);
   			    
   			    while ($rows=$syres->fetch_assoc()){
   			        echo "<div class='weibo-box clearfix'>";
   			        
//    			        更多按钮
   			        echo "<div class='btn-group'>";
   			        echo "<button type='button' class='btn btn-default dropdown-toggle' data-toggle='dropdown' aria-haspopup='true' aria-expanded='false'>
                                更多 <span class='caret'></span></button>";
   			        echo "<ul class='dropdown-menu'>";
   			        if($rows['author']==$_SESSION['user']){
   			            echo "<li><a href='javascript:' onclick=delWb(".$rows['weibo_id'].")>删除</a></li>";
   			        }else{
   			            echo "<li><a href='javascript:' onclick=comWb(".$rows['weibo_id'].")>投诉</a></li>";
   			        }
   			        echo "</ul></div>";
   			        //    			头像
   			        echo "<div class='author-tx'>";
   			        echo "<img src='../".$rows['user_tx']."' style='width: 50px; height:50px; border-radius: 50px'></div>";
   			        //    			微博版心
   			        echo "<div class='weibo-warp'><div class='author-name'><a href='person_loginafter.php?id=".$rows['user_id']."'>".$rows['user_name']."</a></div>";
   			        //    			发布时间
   			        echo "<div class='weibo-time'>".$rows['public_time']."</div>";
   			        echo "<div class='weibo-content'>".$rows['weibo_content']."</div>";
   			        //    			不是转发的
   			        if($rows['weibo_img']){
   			            echo "<div class='weibo-photo'><img src='../".$rows['weibo_img']."' style='height: 167px; width: auto'></div>";
   			        }
   			        //    			转发的
   			        if($rows['relwb_id']!=""){
   			            $relsql = "select weibo_list.*, weibo_user.* from weibo_list, weibo_user where weibo_list.author=weibo_user.user_name and weibo_list.weibo_id='".$rows['relwb_id']."'";
   			            $relres = $conn->query($relsql);
   			            if($relres->num_rows){
   			                $relrow = $relres->fetch_assoc();
   			                
   			                //    			转发的
   			                echo "<div class='rel-weibo'>";
   			                //    			源微博用户名
   			                echo "<div class='author-name'><a href='person_loginafter.php?id=".$relrow['user_id']."'>@".$relrow['author']."</a></div>";
   			                //    			源微博文本
   			                echo "<a href='detail_loginafter.php?id=".$relrow['weibo_id']."'><div class='weibo-content'>".$relrow['weibo_content']."</div>";
   			                //    			源微博图片
   			                if($relrow['weibo_img']){
   			                    echo "<div class='weibo-photo'><img src='../".$relrow['weibo_img']."' style='height: 167px; width: auto'></div>";
   			                }
   			                //    			源微博时间及操作
   			                echo "<div class='relweibo-pobox clearfix'>";
   			                //    			源微博时间
   			                echo "<span class='relweibo-time'>".$relrow['public_time']."</span>";
   			                
   			                $rrsql = "select * from weibo_list where relwb_id = ".$relrow['weibo_id'];
   			                $rrres = $conn->query($rrsql);
   			                
   			                $rcsql = "select * from weibo_comment where weibo_id = ".$relrow['weibo_id'];
   			                $rcres = $conn->query($rcsql);
   			                $rkcsql = "select * from weibo_kidcomment where weibo_id = ".$relrow['weibo_id'];
   			                $rkcres = $conn->query($rkcsql);
   			                $rcnum = ($rcres->num_rows)+($rkcres->num_rows);
   			                //    			源文本操作
   			                echo "<div class='relweibo-op'>";
   			                echo "<span><em class='glyphicon glyphicon-comment'></em><em>".$rcnum."</em></span>";
   			                echo "<span><em class='glyphicon glyphicon-share-alt'></em><em>".$rrres->num_rows."</em></span>";
   			                echo "<span><em class='glyphicon glyphicon-thumbs-up'></em><em>".$relrow['weibo_zan']."</em></span></div></div></a></div>";
   			            }else{
   			                echo "<div class='rel-weibo'>该内容涉嫌违规，已被删除</div>";
   			            }
   			        }
   			        echo "</div>";
   			        
   			        $rsql = "select * from weibo_list where relwb_id = ".$rows['weibo_id'];
   			        $rres = $conn->query($rsql);
   			        
   			        $csql = "select * from weibo_comment where weibo_id = ".$rows['weibo_id'];
   			        $cres = $conn->query($csql);
   			        $kcsql = "select * from weibo_kidcomment where weibo_id = ".$rows['weibo_id'];
   			        $kcres = $conn->query($kcsql);
   			        $cnum = ($cres->num_rows)+($kcres->num_rows);
   			        //    			微博操作
   			        echo "<div class='weibo-op'><a href='detail_loginafter.php?id=".$rows['weibo_id']."&page=1'><span>";
   			        echo "<em class='glyphicon glyphicon-comment'></em><em>".$cnum."</em></span></a>";
   			        echo "<a href='detail_loginafter.php?id=".$rows['weibo_id']."&page=2'><span><em class='glyphicon glyphicon-share-alt'></em>";
   			        echo "<em>".$rres->num_rows."</em></span></a>";
   			        echo "<a href='detail_loginafter.php?id=".$rows['weibo_id']."'><span><em class='glyphicon glyphicon-thumbs-up'></em>";
   			        echo "<em>".$rows['weibo_zan']."</em></span></a></div></div>";
   			    }
   			    
   			}else{
   			    echo "<div class='weibo-box'><span>先关注几个博主吧</span></div>";
   			}
   			?>
   			
   			
        </div>

        <!--我的收藏-->
        <div class="warp-sc">
            <!--顶条-->
            <div class="tip-bar">
                <span>我的收藏</span>
            </div>

            <!--微博-->
            <?php 
            if($scres->num_rows){
                while ($rows=$scres->fetch_assoc()){
                    echo "<div class='weibo-box clearfix'>";
                    //    			头像
                    echo "<div class='author-tx'>";
                    echo "<img src='../".$rows['user_tx']."' style='width: 50px; height:50px; border-radius: 50px'></div>";
                    //    			微博版心
                    echo "<div class='weibo-warp'><div class='author-name'><a href='person_loginafter.php?id=".$rows['user_id']."'>".$rows['author']."</a></div>";
                    //    			发布时间
                    echo "<div class='weibo-time'>".$rows['public_time']."</div>";
                    echo "<div class='weibo-content'>".$rows['weibo_content']."</div>";
                    //    			不是转发的
                    if($rows['weibo_img']){
                        echo "<div class='weibo-photo'><img src='../".$rows['weibo_img']."' style='height: 167px; width: auto'></div>";
                    }
                    if($rows['relwb_id']!=''){
                        $relsql = "select weibo_list.*, weibo_user.* from weibo_list, weibo_user where weibo_list.author=weibo_user.user_name and weibo_list.weibo_id='".$rows['relwb_id']."'";
                        $relres = $conn->query($relsql);
                        if($relres->num_rows){
                            $relrow = $relres->fetch_assoc();
                            
                            //    			转发的
                            echo "<div class='rel-weibo'>";
                            //    			源微博用户名
                            echo "<div class='author-name'><a href='person_loginafter.php?id=".$relrow['user_id']."'>@".$relrow['author']."</a></div>";
                            //    			源微博文本
                            echo "<a href='detail_loginafter.php?id=".$relrow['weibo_id']."'><div class='weibo-content'>".$relrow['weibo_content']."</div>";
                            //    			源微博图片
                            if($relrow['weibo_img']){
                                echo "<div class='weibo-photo'><img src='../".$relrow['weibo_img']."' style='height: 167px; width: auto'></div>";
                            }
                            //    			源微博时间及操作
                            echo "<div class='relweibo-pobox clearfix'>";
                            //    			源微博时间
                            echo "<span class='relweibo-time'>".$relrow['public_time']."</span>";
                            
                            $rrsql = "select * from weibo_list where relwb_id = ".$relrow['weibo_id'];
                            $rrres = $conn->query($rrsql);
                            
                            $rcsql = "select * from weibo_comment where weibo_id = ".$relrow['weibo_id'];
                            $rcres = $conn->query($rcsql);
                            $rkcsql = "select * from weibo_kidcomment where weibo_id = ".$relrow['weibo_id'];
                            $rkcres = $conn->query($rkcsql);
                            $rcnum = ($rcres->num_rows)+($rkcres->num_rows);
                            //    			源文本操作
                            echo "<div class='relweibo-op'>";
                            echo "<span><em class='glyphicon glyphicon-comment'></em><em>".$rcnum."</em></span>";
                            echo "<span><em class='glyphicon glyphicon-share-alt'></em><em>".$rrres->num_rows."</em></span>";
                            echo "<span><em class='glyphicon glyphicon-thumbs-up'></em><em>".$relrow['weibo_zan']."</em></span></div></div></a></div>";
                        }else{
                            echo "<div class='rel-weibo'>该内容涉嫌违规，已被删除</div>";
                        }
                    }
                    echo "</div>";
                    
                    $rsql = "select * from weibo_list where relwb_id = ".$rows['weibo_id'];
                    $rres = $conn->query($rsql);
                    
                    $csql = "select * from weibo_comment where weibo_id = ".$rows['weibo_id'];
                    $cres = $conn->query($csql);
                    $kcsql = "select * from weibo_kidcomment where weibo_id = ".$rows['weibo_id'];
                    $kcres = $conn->query($kcsql);
                    $cnum = ($cres->num_rows)+($kcres->num_rows);
                    //    			微博操作
                    echo "<div class='weibo-op'><a href='detail_loginafter.php?id=".$rows['weibo_id']."&page=1'><span>";
                    echo "<em class='glyphicon glyphicon-comment'></em><em>".$cnum."</em></span></a>";
                    echo "<a href='detail_loginafter.php?id=".$rows['weibo_id']."&page=2'><span><em class='glyphicon glyphicon-share-alt'></em>";
                    echo "<em>".$rres->num_rows."</em></span></a>";
                    echo "<a href='detail_loginafter.php?id=".$rows['weibo_id']."'><span><em class='glyphicon glyphicon-thumbs-up'></em>";
                    echo "<em>".$rows['weibo_zan']."</em></span></a></div></div>";
                }
                
            }else {
                echo "<div class='weibo-box'>您还没有收藏微博哦！</div>";
            }
   			
   			?>

        </div>

        <!--我的赞-->
        <div class="warp-zan">
            <!--顶条-->
            <div class="tip-bar">
                <span>我的赞</span>
            </div>

            <!--微博-->
            <?php 
            if($zanres->num_rows){
                while ($rows=$zanres->fetch_assoc()){
                    echo "<div class='weibo-box clearfix'>";
                    //    			头像
                    echo "<div class='author-tx'>";
                    echo "<img src='../".$rows['user_tx']."' style='width: 50px; height:50px; border-radius: 50px'></div>";
                    //    			微博版心
                    echo "<div class='weibo-warp'><div class='author-name'><a href='person_loginafter.php?id=".$rows['user_id']."'>".$rows['author']."</a></div>";
                    //    			发布时间
                    echo "<div class='weibo-time'>".$rows['public_time']."</div>";
                    echo "<div class='weibo-content'>".$rows['weibo_content']."</div>";
                    //    			不是转发的
                    if($rows['weibo_img']){
                        echo "<div class='weibo-photo'><img src='../".$rows['weibo_img']."' style='height: 167px; width: auto'></div>";
                    }
                    if($rows['relwb_id']!=''){
                        $relsql = "select weibo_list.*, weibo_user.* from weibo_list, weibo_user where weibo_list.author=weibo_user.user_name and weibo_list.weibo_id='".$rows['relwb_id']."'";
                        $relres = $conn->query($relsql);
                        if($relres->num_rows){
                            $relrow = $relres->fetch_assoc();
                            
                            //    			转发的
                            echo "<div class='rel-weibo'>";
                            //    			源微博用户名
                            echo "<div class='author-name'><a href='person_loginafter.php?id=".$relrow['user_id']."'>@".$relrow['author']."</a></div>";
                            //    			源微博文本
                            echo "<a href='detail_loginafter.php?id=".$relrow['weibo_id']."'><div class='weibo-content'>".$relrow['weibo_content']."</div>";
                            //    			源微博图片
                            if($relrow['weibo_img']){
                                echo "<div class='weibo-photo'><img src='../".$relrow['weibo_img']."' style='height: 167px; width: auto'></div>";
                            }
                            //    			源微博时间及操作
                            echo "<div class='relweibo-pobox clearfix'>";
                            //    			源微博时间
                            echo "<span class='relweibo-time'>".$relrow['public_time']."</span>";
                            
                            $rrsql = "select * from weibo_list where relwb_id = ".$relrow['weibo_id'];
                            $rrres = $conn->query($rrsql);
                            
                            $rcsql = "select * from weibo_comment where weibo_id = ".$relrow['weibo_id'];
                            $rcres = $conn->query($rcsql);
                            $rkcsql = "select * from weibo_kidcomment where weibo_id = ".$relrow['weibo_id'];
                            $rkcres = $conn->query($rkcsql);
                            $rcnum = ($rcres->num_rows)+($rkcres->num_rows);
                            //    			源文本操作
                            echo "<div class='relweibo-op'>";
                            echo "<span><em class='glyphicon glyphicon-comment'></em><em>".$rcnum."</em></span>";
                            echo "<span><em class='glyphicon glyphicon-share-alt'></em><em>".$rrres->num_rows."</em></span>";
                            echo "<span><em class='glyphicon glyphicon-thumbs-up'></em><em>".$relrow['weibo_zan']."</em></span></div></div></a></div>";
                        }else{
                            echo "<div class='rel-weibo'>该内容涉嫌违规，已被删除</div>";
                        }
                    }
                    echo "</div>";
                    
                    $rsql = "select * from weibo_list where relwb_id = ".$rows['weibo_id'];
                    $rres = $conn->query($rsql);
                    
                    $csql = "select * from weibo_comment where weibo_id = ".$rows['weibo_id'];
                    $cres = $conn->query($csql);
                    $kcsql = "select * from weibo_kidcomment where weibo_id = ".$rows['weibo_id'];
                    $kcres = $conn->query($kcsql);
                    $cnum = ($cres->num_rows)+($kcres->num_rows);
                    //    			微博操作
                    echo "<div class='weibo-op'><a href='detail_loginafter.php?id=".$rows['weibo_id']."&page=1'><span>";
                    echo "<em class='glyphicon glyphicon-comment'></em><em>".$cnum."</em></span></a>";
                    echo "<a href='detail_loginafter.php?id=".$rows['weibo_id']."&page=2'><span><em class='glyphicon glyphicon-share-alt'></em>";
                    echo "<em>".$rres->num_rows."</em></span></a>";
                    echo "<a href='detail_loginafter.php?id=".$rows['weibo_id']."'><span><em class='glyphicon glyphicon-thumbs-up'></em>";
                    echo "<em>".$rows['weibo_zan']."</em></span></a></div></div>";
                }
                
            }else {
                echo "<div class='weibo-box'>您还没有点赞微博哦！</div>";
            }
   			
   			?>
        </div>

        <!--热门微博-->
        <div class="warp-hot">
            <!--顶条-->
            <div class="tip-bar">
                <span>热门微博</span>
            </div>

            <!--微博-->
            <?php 
            if($hotres->num_rows){
                while ($rows=$hotres->fetch_assoc()){
                    echo "<div class='weibo-box clearfix'>";
                    //    			        更多按钮
                    echo "<div class='btn-group'>";
                    echo "<button type='button' class='btn btn-default dropdown-toggle' data-toggle='dropdown' aria-haspopup='true' aria-expanded='false'>
                                更多 <span class='caret'></span></button>";
                    echo "<ul class='dropdown-menu'>";
                    if($rows['author']==$_SESSION['user']){
                        echo "<li><a href='javascript:' onclick=delWb(".$rows['weibo_id'].")>删除</a></li>";
                    }else{
                        echo "<li><a href='javascript:' onclick=comWb(".$rows['weibo_id'].")>投诉</a></li>";
                    }
                    echo "</ul></div>";
                    //    			头像
                    echo "<div class='author-tx'>";
                    echo "<img src='../".$rows['user_tx']."' style='width: 50px; height:50px; border-radius: 50px'></div>";
                    //    			微博版心
                    echo "<div class='weibo-warp'><div class='author-name'><a href='person_loginafter.php?id=".$rows['user_id']."'>".$rows['author']."</a></div>";
                    //    			发布时间
                    echo "<div class='weibo-time'>".$rows['public_time']."</div>";
                    echo "<div class='weibo-content'>".$rows['weibo_content']."</div>";
                    //    			不是转发的
                    if($rows['weibo_img']){
                        echo "<div class='weibo-photo'><img src='../".$rows['weibo_img']."' style='height: 167px; width: auto'></div>";
                    }
                    if($rows['relwb_id']!=''){
                        $relsql = "select weibo_list.*, weibo_user.* from weibo_list, weibo_user where weibo_list.author=weibo_user.user_name and weibo_list.weibo_id='".$rows['relwb_id']."'";
                        $relres = $conn->query($relsql);
                        if($relres->num_rows){
                            $relrow = $relres->fetch_assoc();
                            
                            //    			转发的
                            echo "<div class='rel-weibo'>";
                            //    			源微博用户名
                            echo "<div class='author-name'><a href='person_loginafter.php?id=".$relrow['user_id']."'>@".$relrow['author']."</a></div>";
                            //    			源微博文本
                            echo "<a href='detail_loginafter.php?id=".$relrow['weibo_id']."'><div class='weibo-content'>".$relrow['weibo_content']."</div>";
                            //    			源微博图片
                            if($relrow['weibo_img']){
                                echo "<div class='weibo-photo'><img src='../".$relrow['weibo_img']."' style='height: 167px; width: auto'></div>";
                            }
                            //    			源微博时间及操作
                            echo "<div class='relweibo-pobox clearfix'>";
                            //    			源微博时间
                            echo "<span class='relweibo-time'>".$relrow['public_time']."</span>";
                            
                            $rrsql = "select * from weibo_list where relwb_id = ".$relrow['weibo_id'];
                            $rrres = $conn->query($rrsql);
                            
                            $rcsql = "select * from weibo_comment where weibo_id = ".$relrow['weibo_id'];
                            $rcres = $conn->query($rcsql);
                            $rkcsql = "select * from weibo_kidcomment where weibo_id = ".$relrow['weibo_id'];
                            $rkcres = $conn->query($rkcsql);
                            $rcnum = ($rcres->num_rows)+($rkcres->num_rows);
                            //    			源文本操作
                            echo "<div class='relweibo-op'>";
                            echo "<span><em class='glyphicon glyphicon-comment'></em><em>".$rcnum."</em></span>";
                            echo "<span><em class='glyphicon glyphicon-share-alt'></em><em>".$rrres->num_rows."</em></span>";
                            echo "<span><em class='glyphicon glyphicon-thumbs-up'></em><em>".$relrow['weibo_zan']."</em></span></div></div></a></div>";
                        }else{
                            echo "<div class='rel-weibo'>该内容涉嫌违规，已被删除</div>";
                        }
                    }
                    echo "</div>";
                    
                    $rsql = "select * from weibo_list where relwb_id = ".$rows['weibo_id'];
                    $rres = $conn->query($rsql);
                    
                    $csql = "select * from weibo_comment where weibo_id = ".$rows['weibo_id'];
                    $cres = $conn->query($csql);
                    $kcsql = "select * from weibo_kidcomment where weibo_id = ".$rows['weibo_id'];
                    $kcres = $conn->query($kcsql);
                    $cnum = ($cres->num_rows)+($kcres->num_rows);
                    //    			微博操作
                    echo "<div class='weibo-op'><a href='detail_loginafter.php?id=".$rows['weibo_id']."&page=1'><span>";
                    echo "<em class='glyphicon glyphicon-comment'></em><em>".$cnum."</em></span></a>";
                    echo "<a href='detail_loginafter.php?id=".$rows['weibo_id']."&page=2'><span><em class='glyphicon glyphicon-share-alt'></em>";
                    echo "<em>".$rres->num_rows."</em></span></a>";
                    echo "<a href='detail_loginafter.php?id=".$rows['weibo_id']."'><span><em class='glyphicon glyphicon-thumbs-up'></em>";
                    echo "<em>".$rows['weibo_zan']."</em></span></a></div></div>";
                }
                
            }else {
                echo "<div class='weibo-box'>暂无热门微博</div>";
            }
   			
   			?>
        </div>

        <!--最新微博-->
        <div class="warp-new">
            <!--顶条-->
            <div class="tip-bar">
                <span>最新微博</span>
            </div>

            <!--微博-->
            <?php 
            if($newres->num_rows){
                while ($rows=$newres->fetch_assoc()){
                    echo "<div class='weibo-box clearfix'>";
                    //    			        更多按钮
                    echo "<div class='btn-group'>";
                    echo "<button type='button' class='btn btn-default dropdown-toggle' data-toggle='dropdown' aria-haspopup='true' aria-expanded='false'>
                                更多 <span class='caret'></span></button>";
                    echo "<ul class='dropdown-menu'>";
                    if($rows['author']==$_SESSION['user']){
                        echo "<li><a href='javascript:' onclick=delWb(".$rows['weibo_id'].")>删除</a></li>";
                    }else{
                        echo "<li><a href='javascript:' onclick=comWb(".$rows['weibo_id'].")>投诉</a></li>";
                    }
                    echo "</ul></div>";
                    //    			头像
                    echo "<div class='author-tx'>";
                    echo "<img src='../".$rows['user_tx']."' style='width: 50px; height:50px; border-radius: 50px'></div>";
                    //    			微博版心
                    echo "<div class='weibo-warp'><div class='author-name'><a href='person.php?id=".$rows['user_id']."'>".$rows['author']."</a></div>";
                    //    			发布时间
                    echo "<div class='weibo-time'>".$rows['public_time']."</div>";
                    echo "<div class='weibo-content'>".$rows['weibo_content']."</div>";
                    //    			不是转发的
                    if($rows['weibo_img']){
                        echo "<div class='weibo-photo'><img src='../".$rows['weibo_img']."' style='height: 167px; width: auto'></div>";
                    }
                    if($rows['relwb_id']!=''){
                        $relsql = "select weibo_list.*, weibo_user.* from weibo_list, weibo_user where weibo_list.author=weibo_user.user_name and weibo_list.weibo_id='".$rows['relwb_id']."'";
                        $relres = $conn->query($relsql);
                        if($relres->num_rows){
                            $relrow = $relres->fetch_assoc();
                            
                            //    			转发的
                            echo "<div class='rel-weibo'>";
                            //    			源微博用户名
                            echo "<div class='author-name'><a href='person_loginafter.php?id=".$relrow['user_id']."'>@".$relrow['author']."</a></div>";
                            //    			源微博文本
                            echo "<a href='detail_loginafter.php?id=".$relrow['weibo_id']."'><div class='weibo-content'>".$relrow['weibo_content']."</div>";
                            //    			源微博图片
                            if($relrow['weibo_img']){
                                echo "<div class='weibo-photo'><img src='../".$relrow['weibo_img']."' style='height: 167px; width: auto'></div>";
                            }
                            //    			源微博时间及操作
                            echo "<div class='relweibo-pobox clearfix'>";
                            //    			源微博时间
                            echo "<span class='relweibo-time'>".$relrow['public_time']."</span>";
                            
                            $rrsql = "select * from weibo_list where relwb_id = ".$relrow['weibo_id'];
                            $rrres = $conn->query($rrsql);
                            
                            $rcsql = "select * from weibo_comment where weibo_id = ".$relrow['weibo_id'];
                            $rcres = $conn->query($rcsql);
                            $rkcsql = "select * from weibo_kidcomment where weibo_id = ".$relrow['weibo_id'];
                            $rkcres = $conn->query($rkcsql);
                            $rcnum = ($rcres->num_rows)+($rkcres->num_rows);
                            //    			源文本操作
                            echo "<div class='relweibo-op'>";
                            echo "<span><em class='glyphicon glyphicon-comment'></em><em>".$rcnum."</em></span>";
                            echo "<span><em class='glyphicon glyphicon-share-alt'></em><em>".$rrres->num_rows."</em></span>";
                            echo "<span><em class='glyphicon glyphicon-thumbs-up'></em><em>".$relrow['weibo_zan']."</em></span></div></div></a></div>";
                        }else{
                            echo "<div class='rel-weibo'>该内容涉嫌违规，已被删除</div>";
                        }
                    }
                    echo "</div>";
                    
                    $rsql = "select * from weibo_list where relwb_id = ".$rows['weibo_id'];
                    $rres = $conn->query($rsql);
                    
                    $csql = "select * from weibo_comment where weibo_id = ".$rows['weibo_id'];
                    $cres = $conn->query($csql);
                    $kcsql = "select * from weibo_kidcomment where weibo_id = ".$rows['weibo_id'];
                    $kcres = $conn->query($kcsql);
                    $cnum = ($cres->num_rows)+($kcres->num_rows);
                    //    			微博操作
                    echo "<div class='weibo-op'><a href='detail_loginafter.php?id=".$rows['weibo_id']."&page=1'><span>";
                    echo "<em class='glyphicon glyphicon-comment'></em><em>".$cnum."</em></span></a>";
                    echo "<a href='detail_loginafter.php?id=".$rows['weibo_id']."&page=2'><span><em class='glyphicon glyphicon-share-alt'></em>";
                    echo "<em>".$rres->num_rows."</em></span></a>";
                    echo "<a href='detail_loginafter.php?id=".$rows['weibo_id']."'><span><em class='glyphicon glyphicon-thumbs-up'></em>";
                    echo "<em>".$rows['weibo_zan']."</em></span></a></div></div>";
                }
                
            }else {
                echo "<div class='weibo-box'>暂无最新微博</div>";
            }
   			
   			?>
        </div>
    </div>

    <!--版心右边-->
    <div class="right-warp">
        <!--个人板块-->
        <div class="person-box">
            <!--背景板块-->
            <div class="bg-box">
                <!--头像板块-->
                <img src="../<?php echo $userrow['user_tx']?>" style="width: 60px; height: 60px; border-radius: 50%" class="person-tx">
            </div>
            <!--个人消息板块-->
            <div class="person-info">
                <p><a href="person_loginafter.php?id=<?php echo $userrow['user_id']?>"><?php echo $userrow['user_name']?></a></p>
                <div class="person-all">
                    <a href="relation.php?id=<?php echo $userrow['user_id']?>&page=1">
                        <strong><?php echo $gzres->num_rows?></strong>
                        <span>关注</span>
                    </a>
                    <a href="relation.php?id=<?php echo $userrow['user_id']?>&page=2">
                        <strong><?php echo $fanres->num_rows?></strong>
                        <span>粉丝</span>
                    </a>
                    <a href="person_loginafter.php?id=<?php echo $userrow['user_id']?>">
                        <strong><?php echo $wbres->num_rows?></strong>
                        <span>微博</span>
                    </a>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<!--脚本-->
<script>
    function delWb(id){
    	var tipDelWb = confirm("你确定要删除此条微博？")
    	if(tipDelWb){
    		$.ajax({
                type:"post",
        		url:"method/delwb_action.php",
        		data:{id: id},
        		success:function(data){
        				alert(data)
        		}
            });
    		location.reload();
    	}
    }
    function comWb(id){
    	var tipComWb = confirm("你确定要投诉此条微博？")
    	if(tipComWb){
    		$.ajax({
                type:"post",
        		url:"method/complaintwb_action.php",
        		data:{id: id},
        		success:function(data){
        				alert(data)
        		}
            });
    	}
    }

    // 点击左边导航条跳转页面
    if(<?php echo $page?>=='1'){
    	$(".list-group-item").removeClass("click")
        $("#nav-1").addClass("click")
        $(".warp-sy").removeClass("choose-2")
        $(".warp-sc").removeClass("choose-2")
        $(".warp-zan").removeClass("choose-2")
        $(".warp-hot").removeClass("choose-2")
        $(".warp-new").removeClass("choose-2")
        $(".warp-sy").addClass("choose-2")
    }else if(<?php echo $page?>==2){
    	$(".list-group-item").removeClass("click")
        $("#nav-2").addClass("click")
        $(".warp-sy").removeClass("choose-2")
        $(".warp-sc").removeClass("choose-2")
        $(".warp-zan").removeClass("choose-2")
        $(".warp-hot").removeClass("choose-2")
        $(".warp-new").removeClass("choose-2")
        $(".warp-sc").addClass("choose-2")
    }else if(<?php echo $page?>==3){
    	$(".list-group-item").removeClass("click")
        $("#nav-3").addClass("click")
        $(".warp-sy").removeClass("choose-2")
        $(".warp-sc").removeClass("choose-2")
        $(".warp-zan").removeClass("choose-2")
        $(".warp-hot").removeClass("choose-2")
        $(".warp-new").removeClass("choose-2")
        $(".warp-zan").addClass("choose-2")
    }else if(<?php echo $page?>==4){
    	$(".list-group-item").removeClass("click")
        $("#nav-4").addClass("click")
        $(".warp-sy").removeClass("choose-2")
        $(".warp-sc").removeClass("choose-2")
        $(".warp-zan").removeClass("choose-2")
        $(".warp-hot").removeClass("choose-2")
        $(".warp-new").removeClass("choose-2")
        $(".warp-hot").addClass("choose-2")
    }else if(<?php echo $page?>==5){
    	$(".list-group-item").removeClass("click")
        $("#nav-5").addClass("click")
        $(".warp-sy").removeClass("choose-2")
        $(".warp-sc").removeClass("choose-2")
        $(".warp-zan").removeClass("choose-2")
        $(".warp-hot").removeClass("choose-2")
        $(".warp-new").removeClass("choose-2")
        $(".warp-new").addClass("choose-2")
    }

</script>
</html>